package dishiyizhou;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

class CalculateTask implements Callable<Integer>{
	private int n;
	public CalculateTask(int n) {
		this.n = n;
	}

	@Override
	public Integer call() throws Exception {
		// TODO Auto-generated method stub 
        return Fibo(this.n);  
	}
	private Integer Fibo(int n1) {
		// TODO Auto-generated method stub
		if (n1 < 2) return 1;
		return Fibo(n1 - 1)+Fibo(n1 - 2);
	}
	
}

public class Main4 {

	 public static void main(String[] args) throws InterruptedException {
	        ExecutorService exec = Executors.newCachedThreadPool();
	        Scanner sc = new Scanner(System.in);
	        int n = sc.nextInt();//num of tasks
	        List<CalculateTask> taskList = new ArrayList<CalculateTask>();
	        List<Future<Integer>> results = new ArrayList<Future<Integer>>();
	        int sum = 0;

	        for (int i = 0; i < n; i++) {
	        	CalculateTask t1 = new CalculateTask(i);
	        	taskList.add(t1);
			}
			results = exec.invokeAll(taskList);
	        for (Future<Integer> future : results) {
				try {
					sum += future.get();
				} catch (ExecutionException e) {
					// TODO Auto-generated catch block
					System.out.println(e);
				}
			}
	        exec.shutdown();
	        System.out.println("sum= "+sum);
	        sc.close();
	}

}
